<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ModuleHelper
 *
 * @author zelic
 */
class ModuleHelper {

    public static function getModules() {
        $ret = array();
        if (Config::getConfig("system", "module") == "1") {
            $path = "../app/";
            $items = scandir($path);
            foreach ($items as $item) {
                if (is_dir($path . $item) && ($item != ".") && ($item != "..")) {
                    $ret[] = $item;
                }
            }
        }
        return $ret;
    }

    public static function getControllers($module = null) {
        $ret = array();
        $path = "";
        if ((Config::getConfig("system", "module") == "1") && ($module != null)) {
            $path = "../app/$module/controller/";
        } else {
            $path = "../app/controller";
        }
        $items = scandir($path);
        foreach ($items as $item) {
            if (is_file($path . $item)) {
                $item = strtolower(substr($item, 0, strlen($item)-strlen("Controller.php")));
                $ret[] = $item;
            }
        }
        return $ret;
    }

}

?>
